﻿package com.calefk.core {
	
	import com.calefk.core.Entity;
	import com.calefk.core.DepthManager;
	import com.calefk.util.Generic;
	import flash.display.MovieClip;
    /**
     * Entidad que puede colocarse un parametro de profundidad. (Equivalente al depth de AS2)
     */
	public class EntityDepth extends Entity {
		
		protected var mDManager:DepthManager;
		protected var mDepth:int;
        
        public function get depth():int { return mDepth; }
		
		public function EntityDepth(dManager:DepthManager, depth:int , nameClip:String = null, 
				px:Number = 0, py:Number = 0 , project:Project = null) {
					
			mDManager = dManager;
			mDepth = depth;
			mProject = project;
			
            mClip = (nameClip == null)?new MovieClip():project.getMovie(nameClip);
            mClip.gotoAndStop(1);
			
			x = px;
			y = py;
			mDManager.addChildAt(mClip , depth);
		}
		
		override public function clean():void {
			super.clean();
			mDManager.removeChild(mClip);
			mDManager = null;
			mClip = null;
            mProject = null;
		}
	}

}